//+------------------------------------------------------------------+ //| Affichage JOUR.mq4 | //| Copyright © 2007, GwadaTradeBoy Corp. | //| racooni_1975@yahoo.fr | //+------------------------------------------------------------------+ //| i-5days.mq4 | //| Copyright © 2007, RickD | //| www.e2e-fx.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, GwadaTradeBoy Corp." #property link "racooni_1975@yahoo.fr" #property copyright "© RickD 2006" #property link "www.e2e-fx.net" //---- #define major 1 #define minor 0 //---- #property indicator_chart_window extern string __1__ = ""; extern int MaxDays = 20; extern int FontSize = 16; extern string FontName = "System"; extern int Offset = 16; extern string __2__ = ""; /*//--- Français extern string Text1 = "Lun"; extern string Text2 = "Mar"; extern string Text3 = "Mer"; extern string Text4 = "Jeu"; extern string Text5 = "Ven"; --- English extern string Text1 = "mon"; extern string Text2 = "tue"; extern string Text3 = "wed"; extern string Text4 = "thu"; extern string Text5 = "fri";*/ //--- Portuguese-Brazilian extern string Text1 = "seg"; extern string Text2 = "ter"; extern string Text3 = "qua"; extern string Text4 = "qui"; extern string Text5 = "sex"; extern string __3__ = ""; extern color Color1 = DodgerBlue; extern color Color2 = DeepPink; extern color Color3 = ForestGreen; extern color Color4 = FireBrick; extern color Color5 = MediumPurple; extern string __4__ = ""; extern bool ShowDay1 = true; extern bool ShowDay2 = true; extern bool ShowDay3 = true; extern bool ShowDay4 = true; extern bool ShowDay5 = true; extern string __5__ = ""; extern bool ShowDayBox = true; extern color DayColor1 = SkyBlue; extern color DayColor2 = Pink; extern color DayColor3 = SpringGreen; extern color DayColor4 = LightCoral; extern color DayColor5 = Plum; //---- string Text[5]; color Color[5]; bool ShowDay[5]; string prefix = "5days_"; //---- Variables - Affichage jour int P, cnt, i, res, day; string name = ""; //---- Variables - Affichage rectangle datetime DateTrade, TimeBeginObject, TimeEndObject; int counted_bars, BarBegin, BarEnd, ResObject; double PriceHighObject, PriceLowObject; string NameObject; color DayColor[5]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators Text[0] = Text1; Text[1] = Text2; Text[2] = Text3; Text[3] = Text4; Text[4] = Text5; //---- Color[0] = Color1; Color[1] = Color2; Color[2] = Color3; Color[3] = Color4; Color[4] = Color5; DayColor[0] = DayColor1; DayColor[1] = DayColor2; DayColor[2] = DayColor3; DayColor[3] = DayColor4; DayColor[4] = DayColor5; //---- ShowDay[0] = ShowDay1; ShowDay[1] = ShowDay2; ShowDay[2] = ShowDay3; ShowDay[3] = ShowDay4; ShowDay[4] = ShowDay5; //---- clear(); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- clear(); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { counted_bars=IndicatorCounted(); P = Period(); //---- if(P > PERIOD_D1) return; cnt = MathMin(Bars, PERIOD_D1 / P * MaxDays); for(i=0; i < cnt; i++) { if(TimeDayOfWeek(Time[i]) != TimeDayOfWeek(Time[i+1])) { name = prefix + TimeToStr(Time[i]); res = ObjectFind(name); if(res == -1) { day = TimeDayOfWeek(Time[i]); if(!ShowDay[day-1]) continue; ObjectCreate(name, OBJ_TEXT, 0, Time[i], High[i] + Offset * Point); ObjectSetText(name, Text[day-1], FontSize, FontName, Color[day-1]); } if(ShowDayBox && P <= PERIOD_H4) { //---- Définition des variables NameObject = "DayBox"+i; DateTrade = TimeCurrent(); //---- Calcul des valeurs courantes TimeBeginObject = Time[i]; switch(Period()) { case PERIOD_M1: TimeEndObject = Time[i+1440]; break; case PERIOD_M5: TimeEndObject = Time[i+288]; break; case PERIOD_M15: TimeEndObject = Time[i+96]; break; case PERIOD_M30: TimeEndObject = Time[i+48]; break; case PERIOD_H1: TimeEndObject = Time[i+24]; break; case PERIOD_H4: TimeEndObject = Time[i+6]; break; } BarBegin=iBarShift(NULL, 0, TimeBeginObject); BarEnd=iBarShift(NULL, 0, TimeEndObject); PriceHighObject = High[iHighest(NULL, 0, MODE_HIGH, BarBegin - BarEnd, BarEnd)]; PriceLowObject=Low [iLowest (NULL, 0, MODE_LOW , BarBegin - BarEnd, BarEnd)]; //---- Dessin du rectangle ObjectCreate(NameObject, OBJ_RECTANGLE, 0, TimeBeginObject, PriceHighObject, TimeEndObject, PriceLowObject); ObjectSet(NameObject, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(NameObject, OBJPROP_COLOR, DayColor[day-1]); ObjectSet(NameObject, OBJPROP_BACK, True); } } } //---- return(0); } //+------------------------------------------------------------------+ //---- void clear() { P = Period(); if(P > PERIOD_D1) return; cnt = MathMin(Bars, PERIOD_D1 / P * MaxDays); for(i=0; i < cnt; i++) { name = prefix + TimeToStr(Time[i]); NameObject = "DayBox"+i; res = ObjectFind(name); ResObject = ObjectFind(NameObject); if(res != -1) ObjectDelete(name); if(ResObject != -1) ObjectDelete(NameObject); } }